#include<string>
using namespace std;

/**************简单实现基本运算的任务***************/

enum
{
    SUCC,
    DIVZERO,
    MODZERO,
    INVALIDOP
};

class Task
{
public:
    Task(int data1 = 0, int data2 = 0, char oper = 0)
    :_left(data1),_right(data2),_oper(oper),_exitcode(0)
    {}   

    void run()
    {  
        switch(_oper)
        {
            case '+':
                _result = _left + _right;
                break;
            case '-':
                _result = _left - _right;
                break;
            case '*':
                _result = _left * _right;
                break;
            case '/':
                {
                    if(_right == 0)
                    {
                        _exitcode = DIVZERO;
                        _result = -1;
                    }
                    else
                    {
                    _result = _left / _right; 
                    }                    
                }         
                break;
            case '%':
                if(_right == 0)
                {
                    _exitcode = MODZERO;
                    _result = -1;
                }
                else
                {
                   _result = _left % _right; 
                } 
                break;
            default:
                _exitcode = INVALIDOP;
                break;
        }
    }

    //仿函数设计
    void operator()()
    {
        this->run();
    }

    string GetTaskLog()
    {
        return string("Task is: " + to_string(_left) + " " + _oper + " " + to_string(_right) + " =? ");
    }

    string GetResultLog()
    {
        return string ("result is: " + to_string(_result) + " and exitcode is: " + to_string(_exitcode));
    }

private:
    int _left;
    int _right;
    char _oper;
    int _result;
    int _exitcode;
};